package com.fhz.high5kotlin.widget

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.fhz.high5kotlin.R
import java.lang.Deprecated

/**
 * 时间:2023/3/23
 * @author Mr.Feng
 * 简述: TODO
 */
class MyDialog(context : Context) :  Dialog(context) , LifecycleObserver{

    init {
        if(context is ComponentActivity){
            (context as ComponentActivity).lifecycle.addObserver(this)
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialoglayout)
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun onDestroy(){
        if(isShowing){
            dismiss()
        }
    }



}